home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / lib / iceweasel / iceweasel < prev   
Encoding:
Text File  |  2013-01-09  |  3.2 KB  |  141 lines

  1. #!/bin/sh
  2. #
  3. # The contents of this file are subject to the Netscape Public
  4. # License Version 1.1 (the "License"); you may not use this file
  5. # except in compliance with the License. You may obtain a copy of
  6. # the License at http://www.mozilla.org/NPL/
  7. #
  8. # Software distributed under the License is distributed on an "AS
  9. # IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
  10. # implied. See the License for the specific language governing
  11. # rights and limitations under the License.
  12. #
  13. # The Original Code is mozilla.org code.
  14. #
  15. # The Initial Developer of the Original Code is Netscape
  16. # Communications Corporation.  Portions created by Netscape are
  17. # Copyright (C) 1998 Netscape Communications Corporation. All
  18. # Rights Reserved.
  19. #
  20. # Contributor(s): 
  21. #
  22.  
  23. ##
  24. ## For silly people running iceweasel through sudo
  25. ##
  26. if [ "${SUDO_USER}" ] && [ "${SUDO_USER}" != "${USER}" ]; then
  27.     SUDO_HOME=`getent passwd ${SUDO_USER} | cut -f6 -d:`
  28.     if [ "${SUDO_HOME}" = "${HOME}" ]; then
  29.         echo "You shouldn't really run Iceweasel through sudo WITHOUT the -H option." >&2
  30.         echo "Continuing as if you used the -H option." >&2
  31.         HOME=`getent passwd ${USER} | cut -f6 -d:`
  32.         if [ -z "${HOME}" ]; then
  33.             echo "Could not find the correct home directory. Please use the -H option of sudo." >&2
  34.         fi
  35.     fi
  36. fi
  37.  
  38. ##
  39. ## Variables
  40. ##
  41. MOZ_APP_LAUNCHER="$(which $0)"
  42. MOZ_DIST_BIN="$(dirname "$(readlink -f "${MOZ_APP_LAUNCHER}")")"
  43. MOZ_PROGRAM="${MOZ_DIST_BIN}/firefox-bin"
  44. export MOZ_APP_LAUNCHER
  45.  
  46. ##
  47. ## Load system and user properties
  48. ##
  49.  
  50. verbose () {
  51.     if [ "${VERBOSE}" ]; then
  52.         echo $@
  53.     fi
  54. }
  55.  
  56. echo_vars () {
  57.     if [ "${VERBOSE}" ]; then
  58.       for var in "$@"; do
  59.           echo "$var=`eval echo \\${$var}`"
  60.       done
  61.     fi
  62. }
  63.     
  64. # exec wrapper for verbosity
  65. exec_verbose () {
  66.     verbose Running: $@
  67.     exec "$@"
  68. }
  69.  
  70. # exec wrapper for verbosity
  71. run_verbose () {
  72.     verbose Running: $@
  73.     "$@"
  74. }
  75.  
  76. # OK, here's where all the real work gets done
  77.  
  78. # parse command line
  79. VERBOSE=
  80. DEBUG=0
  81. DEBUGGER=
  82. first=1
  83. prev=
  84. for arg in "$@"; do
  85.     if [ ${first} -eq 1 ]; then
  86.         set dummy
  87.         first=0
  88.     fi
  89.  
  90.     if [ "${prev}" ]; then # That can only be --debugger
  91.         DEBUGGER="${arg}"
  92.         prev=
  93.     else
  94.         case "$arg" in
  95.             --verbose | -V)
  96.                 VERBOSE=1
  97.                 ;;
  98.             -g | -debug)
  99.                 DEBUG=1
  100.                 ;;
  101.             --debugger)
  102.                 DEBUG=1
  103.                 prev=${arg}
  104.                 ;;
  105.             *)
  106.                 set "$@" "${arg}"
  107.                 ;;
  108.         esac
  109.     fi
  110. done
  111.  
  112. if [ $# -ne 0 ]; then
  113.     shift
  114. fi
  115. OPTIONS="$@"
  116.  
  117. echo_vars OPTIONS DEBUG DEBUGGER
  118.  
  119. if [ ${DEBUG} -eq 1 ]; then
  120.     if [ "${DEBUGGER}" = "" ]; then
  121.         DEBUGGER=gdb
  122.     fi
  123.     TMPFILE=`mktemp -t iceweasel_argsXXXXXX`
  124.     echo set args "$@" > ${TMPFILE}
  125.     case "${DEBUGGER}" in
  126.         gdb)
  127.             run_verbose gdb "${MOZ_PROGRAM}" -x ${TMPFILE}
  128.             ;;
  129.         ddd)
  130.             run_verbose ddd --debugger "gdb -x ${TMPFILE}" "${MOZ_PROGRAM}"
  131.             ;;
  132.         *)
  133.             run_verbose ${DEBUGGER} "${MOZ_PROGRAM}" "$@"
  134.             ;;
  135.     esac
  136.     rm ${TMPFILE}
  137.     exit
  138. fi
  139.  
  140. exec_verbose ${MOZ_PROGRAM} "$@"
  141.